import React, { Component } from 'react'
import Son from './Son'

export default class Dad extends Component {
    constructor() {
      super()
    this.state = {
        slap: 1
    }
  }
  sonRef = React.createRef()
  boxRef = React.createRef()

  componentDidMount() {
    console.log(this.sonRef.current)
    console.log(this.boxRef.current)
  }
  render() {
    return (
      <div>
        Dad
        <br></br>
        <button onClick={() => {
            this.setState({
                slap: this.state.slap + 1
            })
        }}>再扇一个</button>
        <hr></hr>
        <div ref={this.boxRef} className='box'>123</div>
        <Son ref={this.sonRef} bgColor='pink'>{this.state.slap}</Son>
      </div>
    )
  }
}
